package com.zz.admin.userManagement.controller;

import com.zz.admin.userManagement.dto.UserRoleDto;
import com.zz.admin.userManagement.service.UserRoleService;
import java.util.List;
import com.zz.common.base.dto.PageListResultDto;
import com.zz.common.base.dto.ResponseDTO;
import com.zz.common.base.dto.ResultDto;
import com.zz.common.constants.ApiConstants;

import io.swagger.annotations.Api;
import jakarta.annotation.Resource;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * 用户角色关联表 服务接口类
 * @author zhang.lei
 * @since 2025-04-12 21:20:12
 */
@Api(tags = "用户角色关联表服务接口类")
@RestController
@RequestMapping("user-management/v1.0/user-role")
public class UserRoleController {

    @Resource
    private UserRoleService userRoleService;

    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "用户角色关联表-查询ById", notes = "传入id")
    public ResponseDTO<UserRoleDto> queryById(@PathVariable("id") String id) {
        ResponseDTO<UserRoleDto> res = new ResponseDTO<>();
        UserRoleDto result = userRoleService.queryById(id);
        res.setData(result);
        return res;
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ApiOperation(value = "用户角色关联表-创建", notes = "创建")
    public ResultDto save(@RequestBody UserRoleDto userRoleDto) {
        ResultDto res = new ResultDto();
        userRoleService.save(userRoleDto);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "用户角色关联表-删除ById", notes = "传入id")
    public ResultDto delete(@PathVariable("id")  String id) {
        ResultDto res = new ResultDto();
        userRoleService.delete(id);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

}